home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / cmds / rawstat / RCS / rawstat.c,v < prev    next >
Encoding:
Text File  |  1990-09-24  |  9.0 KB  |  431 lines

  1. head     1.10;
  2. branch   ;
  3. access   ;
  4. symbols  ;
  5. locks    ; strict;
  6. comment  @ * @;
  7.  
  8.  
  9. 1.10
  10. date     90.09.24.14.40.30;  author douglis;  state Exp;
  11. branches ;
  12. next     1.9;
  13.  
  14. 1.9
  15. date     90.05.01.16.50.36;  author douglis;  state Exp;
  16. branches ;
  17. next     1.8;
  18.  
  19. 1.8
  20. date     89.11.07.18.19.42;  author brent;  state Exp;
  21. branches ;
  22. next     1.7;
  23.  
  24. 1.7
  25. date     89.10.24.10.15.16;  author brent;  state Exp;
  26. branches ;
  27. next     1.6;
  28.  
  29. 1.6
  30. date     89.10.11.07.51.32;  author brent;  state Exp;
  31. branches ;
  32. next     1.5;
  33.  
  34. 1.5
  35. date     89.09.11.11.46.15;  author douglis;  state Exp;
  36. branches ;
  37. next     1.4;
  38.  
  39. 1.4
  40. date     89.09.11.10.39.11;  author brent;  state Exp;
  41. branches ;
  42. next     1.3;
  43.  
  44. 1.3
  45. date     89.06.23.16.48.24;  author brent;  state Exp;
  46. branches ;
  47. next     1.2;
  48.  
  49. 1.2
  50. date     89.06.23.16.17.26;  author brent;  state Exp;
  51. branches ;
  52. next     1.1;
  53.  
  54. 1.1
  55. date     89.06.23.15.50.54;  author brent;  state Exp;
  56. branches ;
  57. next     ;
  58.  
  59.  
  60. desc
  61. @Main program for rawstat
  62. @
  63.  
  64.  
  65. 1.10
  66. log
  67. @changes for migration stats
  68. @
  69. text
  70. @/* 
  71.  * rawstat.c --
  72.  *
  73.  *    Print out kerel statitics in a raw format;
  74.  *    <Structure name>
  75.  *    <field> <value>
  76.  *    <field> <value>
  77.  *    <field> <value>
  78.  *
  79.  * Copyright (C) 1986 Regents of the University of California
  80.  * All rights reserved.
  81.  */
  82.  
  83. #ifndef lint
  84. static char rcsid[] = "$Header: /sprite/src/cmds/rawstat/RCS/rawstat.c,v 1.9 90/05/01 16:50:36 douglis Exp Locker: douglis $ SPRITE (Berkeley)";
  85. #endif not lint
  86.  
  87. #include "sprite.h"
  88. #include "fs.h"
  89. #include "fsCmd.h"
  90. #include "stdio.h"
  91. #include "option.h"
  92. #include "vm.h"
  93. #include "sysStats.h"
  94. #include "kernel/vm.h"
  95. #include "kernel/fs.h"
  96. #include "kernel/fsStat.h"
  97. #include "kernel/sched.h"
  98. #include "kernel/procMigrate.h"
  99.  
  100. Boolean doAllFsStats = FALSE;
  101. Boolean doAllVmStats = FALSE;
  102. Boolean doAllRpcStats = FALSE;
  103. Boolean doAllProcStats = FALSE;
  104. Boolean doAllRecovStats = FALSE;
  105. Boolean doAllMigStats = FALSE;
  106. Boolean noIdle    = FALSE;
  107. Boolean zero = FALSE;
  108. Boolean all = FALSE;
  109.  
  110. Option optionArray[] = {
  111.     {OPT_TRUE, "fs", (Address)&doAllFsStats, "Print ALL file system stats"},
  112.     {OPT_TRUE, "vm", (Address)&doAllVmStats, "Print ALL vm stats"},
  113.     {OPT_TRUE, "rpc", (Address)&doAllRpcStats, "Print ALL rpc stats"},
  114.     {OPT_TRUE, "proc", (Address)&doAllProcStats, "Print ALL proc stats"},
  115.     {OPT_TRUE, "recov", (Address)&doAllRecovStats, "Print ALL recov stats"},
  116.     {OPT_TRUE, "mig", (Address)&doAllMigStats, "Print ALL mig stats"},
  117.     {OPT_TRUE, "noidle", (Address)&noIdle, "Don't print idle ticks info"},
  118.     {OPT_TRUE, "zero", (Address)&zero, "Print zero valued stats"},
  119.     {OPT_TRUE, "all", (Address)&all, "Print all stats"},
  120. };
  121. int numOptions = sizeof(optionArray) / sizeof(Option);
  122.  
  123. Fs_Stats fsStats;
  124. Vm_Stat    vmStats;
  125. Fs_TypeStats fsTypeStats;
  126.  
  127. main(argc, argv)
  128.     int argc;
  129.     char *argv[];
  130. {
  131.     int status = SUCCESS;
  132.     int virtualHost, physicalHost;
  133.  
  134.     argc = Opt_Parse(argc, argv, optionArray, numOptions);
  135.  
  136.     if (all) {
  137.     doAllFsStats = TRUE;
  138.     doAllVmStats = TRUE;
  139.     doAllRpcStats = TRUE;
  140.     doAllProcStats = TRUE;
  141.     doAllRecovStats = TRUE;
  142.     doAllMigStats = TRUE;
  143.     }
  144.  
  145.     system("echo RAWSTAT `hostname` `date`");
  146.  
  147.     if (!noIdle) {
  148.     PrintRawIdle();
  149.     }
  150.  
  151.     if (doAllFsStats) {
  152.     status = Fs_Command(FS_RETURN_STATS, sizeof(Fs_Stats), &fsStats);
  153.     if (status != SUCCESS) {
  154.         Stat_PrintMsg(status, "Fs_Command(FS_RETURN_STATS)");
  155.     } else if (fsStats.statsVersion == FS_STAT_VERSION) {
  156.         PrintRawFsCltName(&fsStats.cltName);
  157.         PrintRawFsSrvName(&fsStats.srvName);
  158.         PrintRawFsGen(&fsStats.gen);
  159.         PrintRawFsBlockCache(&fsStats.blockCache);
  160.         PrintRawFsAlloc(&fsStats.alloc);
  161.         PrintRawFsNameCache(&fsStats.nameCache);
  162.         PrintRawFsHandle(&fsStats.handle);
  163.         PrintRawFsPrefix(&fsStats.prefix);
  164.         PrintRawFsLookup(&fsStats.lookup);
  165.         PrintRawFsObject(&fsStats.object);
  166.         PrintRawFsRecovery(&fsStats.recovery);
  167.         PrintRawFsConsist(&fsStats.consist);
  168.         PrintRawFsWriteBack(&fsStats.writeBack);
  169.         PrintRawRemoteIO(&fsStats.rmtIO);
  170.         PrintRawFsMig(&fsStats.mig);
  171.     } else {
  172.         fprintf(stderr,
  173.             "Wrong version of Fs_Stats: kernel is %d, while ours is %d.\n",
  174.             fsStats.statsVersion, FS_STAT_VERSION);
  175.     }
  176.     }
  177.     if (doAllVmStats) {
  178.     int pageSize;
  179.     status = Vm_Cmd(VM_GET_STATS, &vmStats);
  180.     if (status != SUCCESS) {
  181.         Stat_PrintMsg(status, "Vm_Cmd failed");
  182.         exit(status);
  183.     }
  184.     Vm_PageSize(&pageSize);
  185.     PrintRawVmStat(&vmStats);
  186.     printf("\tpagesize %d\n", pageSize);
  187.     }
  188.     if (doAllRpcStats) {
  189.     PrintRawRpcCltStat();
  190.     PrintRawRpcSrvStat();
  191.     PrintSrvCount();
  192.     PrintCallCount();
  193.     }
  194.     if (doAllProcStats) {
  195.     PrintRawProcMigStat();
  196.     }
  197.     if (doAllMigStats) {
  198.     PrintRawMigStat();
  199.     }
  200.     if (doAllRecovStats) {
  201.     PrintRawRecovStat();
  202.     }
  203.     exit(0);
  204. }
  205.  
  206.  
  207. /*
  208.  *----------------------------------------------------------------------
  209.  *
  210.  * PrintRawIdle --
  211.  *
  212.  *    Prints the raw idle ticks of the machine.
  213.  *
  214.  * Results:
  215.  *    None.
  216.  *
  217.  * Side effects:
  218.  *    None.
  219.  *
  220.  *----------------------------------------------------------------------
  221.  */
  222.  
  223. PrintRawIdle()
  224. {
  225.     Sched_Instrument schedStats;
  226.     struct perProcessor *X = &schedStats.processor[0];
  227.     ReturnStatus status;
  228.  
  229.     status = Sys_Stats(SYS_SCHED_STATS, 0, &schedStats);
  230.     if (status != SUCCESS) {
  231.     Stat_PrintMsg(status, "Error in Sys_Stats");
  232.     exit(status);
  233.     }
  234.     printf("numContextSwitches %8u\n", X->numContextSwitches);
  235.     printf("numInvoluntarySwitches %8u\n", X->numInvoluntarySwitches);
  236.     printf("numFullCS      %8u\n", X->numFullCS);
  237.     printf("idleTime       %8d.%06d\n", X->idleTime.seconds,
  238.                         X->idleTime.microseconds);
  239.     printf("idleTicksLow   %8u\n", X->idleTicksLow);
  240.     printf("idleTicksOverflow %8u\n", X->idleTicksOverflow);
  241.     printf("idleTicksPerSecond %8u\n", X->idleTicksPerSecond);
  242.     printf("noInput %8d.%06d\n", schedStats.noUserInput.seconds,
  243.            schedStats.noUserInput.microseconds);
  244.     printf("\n");
  245.  
  246. }
  247.  
  248. /*
  249.  *----------------------------------------------------------------------
  250.  *
  251.  * ZeroPrint --
  252.  *
  253.  *    Prints a field if non-zero or if the global variable zero is set.
  254.  *
  255.  * Results:
  256.  *    None.
  257.  *
  258.  * Side effects:
  259.  *    None.
  260.  *
  261.  *----------------------------------------------------------------------
  262.  */
  263.  
  264. ZeroPrint(format, value)
  265.     char *format;
  266.     int value;
  267. {
  268.     if (zero || value != 0) {
  269.     printf(format, value);
  270.     }
  271. }
  272.  
  273. @
  274.  
  275.  
  276. 1.9
  277. log
  278. @added mig calls
  279. @
  280. text
  281. @d15 1
  282. a15 1
  283. static char rcsid[] = "$Header: /sprite/src/cmds/rawstat/RCS/rawstat.c,v 1.8 89/11/07 18:19:42 brent Exp Locker: douglis $ SPRITE (Berkeley)";
  284. d86 20
  285. a105 1
  286.         exit(status);
  287. a106 14
  288.     PrintRawFsCltName(&fsStats.cltName);
  289.     PrintRawFsSrvName(&fsStats.srvName);
  290.     PrintRawFsGen(&fsStats.gen);
  291.     PrintRawFsBlockCache(&fsStats.blockCache);
  292.     PrintRawFsAlloc(&fsStats.alloc);
  293.     PrintRawFsNameCache(&fsStats.nameCache);
  294.     PrintRawFsHandle(&fsStats.handle);
  295.     PrintRawFsPrefix(&fsStats.prefix);
  296.     PrintRawFsLookup(&fsStats.lookup);
  297.     PrintRawFsObject(&fsStats.object);
  298.     PrintRawFsRecovery(&fsStats.recovery);
  299.     PrintRawFsConsist(&fsStats.consist);
  300.     PrintRawFsWriteBack(&fsStats.writeBack);
  301.     PrintRawRemoteIO(&fsStats.rmtIO);
  302. d173 2
  303. @
  304.  
  305.  
  306. 1.8
  307. log
  308. @Added fs_Stats.rmtIO
  309. @
  310. text
  311. @d15 1
  312. a15 1
  313. static char rcsid[] = "$Header: /sprite/src/cmds/rawstat/RCS/rawstat.c,v 1.7 89/10/24 10:15:16 brent Exp Locker: brent $ SPRITE (Berkeley)";
  314. d36 1
  315. d47 1
  316. d73 1
  317. d123 3
  318. d129 1
  319. @
  320.  
  321.  
  322. 1.7
  323. log
  324. @Added more FS stats
  325. @
  326. text
  327. @d15 1
  328. a15 1
  329. static char rcsid[] = "$Header: /a/newcmds/rawstat/RCS/rawstat.c,v 1.6 89/10/11 07:51:32 brent Exp Locker: brent $ SPRITE (Berkeley)";
  330. d98 1
  331. @
  332.  
  333.  
  334. 1.6
  335. log
  336. @Added -recov stats
  337. @
  338. text
  339. @d15 1
  340. a15 1
  341. static char rcsid[] = "$Header: /a/newcmds/rawstat/RCS/rawstat.c,v 1.5 89/09/11 11:46:15 douglis Exp Locker: brent $ SPRITE (Berkeley)";
  342. d96 2
  343. @
  344.  
  345.  
  346. 1.5
  347. log
  348. @changes for process migration statistics
  349. @
  350. text
  351. @d15 1
  352. a15 1
  353. static char rcsid[] = "$Header: /a/newcmds/rawstat/RCS/rawstat.c,v 1.4 89/09/11 10:39:11 brent Exp Locker: douglis $ SPRITE (Berkeley)";
  354. d35 1
  355. d45 1
  356. d70 1
  357. d116 3
  358. @
  359.  
  360.  
  361. 1.4
  362. log
  363. @Updated to new typedefs
  364. @
  365. text
  366. @d15 1
  367. a15 1
  368. static char rcsid[] = "$Header: /a/newcmds/rawstat/RCS/rawstat.c,v 1.3 89/06/23 16:48:24 brent Exp $ SPRITE (Berkeley)";
  369. d29 1
  370. d34 1
  371. d43 1
  372. d67 1
  373. d110 3
  374. @
  375.  
  376.  
  377. 1.3
  378. log
  379. @Chagned to unsigned print format to handle large numbers
  380. @
  381. text
  382. @d15 1
  383. a15 1
  384. static char rcsid[] = "$Header: /a/newcmds/rawstat/RCS/rawstat.c,v 1.2 89/06/23 16:17:26 brent Exp $ SPRITE (Berkeley)";
  385. d47 1
  386. a47 1
  387. FsStats fsStats;
  388. d49 1
  389. a49 1
  390. FsTypeStats fsTypeStats;
  391. d73 1
  392. a73 1
  393.     status = Fs_Command(FS_RETURN_STATS, sizeof(FsStats), &fsStats);
  394. @
  395.  
  396.  
  397. 1.2
  398. log
  399. @Added -all option
  400. @
  401. text
  402. @d15 1
  403. a15 1
  404. static char rcsid[] = "$Header: /a/newcmds/rawstat/RCS/rawstat.c,v 1.1 89/06/23 15:50:54 brent Exp Locker: brent $ SPRITE (Berkeley)";
  405. d137 3
  406. a139 3
  407.     printf("numContextSwitches %8d\n", X->numContextSwitches);
  408.     printf("numInvoluntarySwitches %8d\n", X->numInvoluntarySwitches);
  409.     printf("numFullCS      %8d\n", X->numFullCS);
  410. d142 3
  411. a144 3
  412.     printf("idleTicksLow   %8d\n", X->idleTicksLow);
  413.     printf("idleTicksOverflow %8d\n", X->idleTicksOverflow);
  414.     printf("idleTicksPerSecond %8d\n", X->idleTicksPerSecond);
  415. @
  416.  
  417.  
  418. 1.1
  419. log
  420. @Initial revision
  421. @
  422. text
  423. @d15 1
  424. a15 1
  425. static char rcsid[] = "$Header: /a/newcmds/fsstat/RCS/fsstat.c,v 1.5 89/06/15 17:46:03 brent Exp $ SPRITE (Berkeley)";
  426. d35 1
  427. d43 1
  428. d56 1
  429. d59 6
  430. @
  431.